#coding = utf-8
s = input('输入字符串')
k = int(input('输入k值'))
start_s = []
grouping_s = []
z = 0
for i in s:                       #去除原始字符串的'-'
    if str(i) != '-':
        start_s.append(i)
reversal_s = start_s[::-1]        #反转字符串
for j in reversal_s:              #按k值分组
    grouping_s.append(j)
    z += 1
    if z == k:
        grouping_s.append('-')
        z = 0
s_end = grouping_s[::-1]          #反转回来
if s_end[0] == '-':
    s_end.remove('-')
print(''.join(s_end).upper())     #小写转大写